package com.yhy.wxzn.wms.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yhy.wxzn.common.enums.*;
import com.yhy.wxzn.common.exception.WmsBusinessException;
import com.yhy.wxzn.common.service.IWmsBusinessService;
import com.yhy.wxzn.common.utils.DateUtil;
import com.yhy.wxzn.wcs.device.rgv.bean.Coord;
import com.yhy.wxzn.wcs.device.rgv.enums.RgvProgress;
import com.yhy.wxzn.wcs.entity.*;
import com.yhy.wxzn.wcs.enums.TaskStatus;
import com.yhy.wxzn.wcs.enums.TaskType;
import com.yhy.wxzn.wcs.service.*;
import com.yhy.wxzn.wms.entity.*;
import com.yhy.wxzn.wms.mapper.WmsBusinessMsgMapper;
import com.yhy.wxzn.wms.service.*;
import org.jeecg.common.system.base.entity.JeecgEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import java.util.Date;
import java.util.List;

/**
 * @Auther: 97354
 * @Date: 2023/12/7 16:09
 * @Description: WmsBusinessMsgServiceImpl
 * @Version 1.0.0
 * WMS消息处理类
 */
@Service
public class WmsBusinessMsgServiceImpl extends ServiceImpl<WmsBusinessMsgMapper, JeecgEntity> implements IWmsBusinessMsgService {
    @Autowired
    private IWcsBcrTaskService wcsBcrTaskService;
    @Autowired
    private IWmsBusinessService businessService;
    @Autowired
    private IWmsPutAwayTaskService putAwayTaskService;
    @Autowired
    private IWcsContainerBindService containerBindService;
    @Autowired
    private IWcsLineTaskService lineTaskService;
    @Autowired
    private IWmsInboundConfigService inboundConfigService;
    @Autowired
    private IWmsInboundDetailService inboundDetailService;
    @Autowired
    private IWcsElevatorTaskService elevatorTaskService;
    @Autowired
    private IWcsFourWayTaskService fourWayTaskService;
    @Autowired
    private IWmsOutboundConfigService outboundConfigService;
    @Autowired
    private IWmsOutboundDetailService outboundDetailService;
    @Autowired
    private IWmsPickTaskService pickTaskService;
    /**
     * 1:入库配置信息按序号升序
     * 2:根据配置的设备类型生成不同设备的任务
     * 3:校验是否已有任务生成
     * */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void dispatchPutAwayTask(WmsAsn asn) {
        List<WmsInboundDetail> details = findInboundConfig(asn);
        if (CollectionUtils.isEmpty(details)) {
            throw new WmsBusinessException("ASN单号:【" + asn.getCode() + "】未找到对应的入库配置明细!");
        }
        LambdaQueryWrapper<WmsPutAwayTask> taskQuery = new LambdaQueryWrapper<>();
        taskQuery.eq(WmsPutAwayTask::getAsnCode, asn.getCode());
        taskQuery.eq(WmsPutAwayTask::getTaskStatus, WmsOrderStatusEnums.XJ.getValue());
        WmsPutAwayTask putTask = putAwayTaskService.getOne(taskQuery);
        if (ObjectUtils.isEmpty(putTask)) {
            throw new WmsBusinessException("ASN单号:【" + asn.getCode() + "】未找到对应的上架任务!");
        }

        /**
         * WMS
         *  分配最佳货位
         */








        Coord coord = null;


        /**
         * WCS
         * 生成入库wcs相关任务
         *
         * 1.通过终点货位找到合适的方案
         * 2.通过方案，生成库口任务、输送线任务、提升机任务、四向车任务。。。
         *
         */
        //coord

        for (WmsInboundDetail inboundDetail: details) {
            int deviceType = inboundDetail.getDeviceType();
            generateDeviceTask(deviceType,putTask,inboundDetail);
        }
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void dispatchGetDownTask(WmsPickOrder pickOrder) {
        List<WmsOutboundDetail> details =findOutboundConfig(pickOrder);
        LambdaQueryWrapper<WmsPickTask> taskQuery = new LambdaQueryWrapper<>();
        taskQuery.eq(WmsPickTask::getPickCode, pickOrder.getCode());
        taskQuery.eq(WmsPickTask::getTaskStatus, WmsOrderStatusEnums.XJ.getValue());
        WmsPickTask pickTask = pickTaskService.getOne(taskQuery);
        if (ObjectUtils.isEmpty(pickTask)) {
            throw new WmsBusinessException("拣货单号:【" + pickTask.getPickCode() + "】未找到对应的下架任务!");
        }
        for (WmsOutboundDetail outboundDetail: details) {
            int deviceType = outboundDetail.getDeviceType();
            generateDeviceTask(deviceType,pickTask,outboundDetail);
        }
    }

    private List<WmsOutboundDetail> findOutboundConfig(WmsPickOrder pickOrder) {
        //查找入库配置
        LambdaQueryWrapper<WmsOutboundConfig> configQuery = new LambdaQueryWrapper<>();
        configQuery.eq(WmsOutboundConfig::getStatus, ValidEnums.ENABLE.getValue());
        configQuery.eq(WmsOutboundConfig::getOrderType, pickOrder.getOrderType());
        WmsOutboundConfig outboundConfig = outboundConfigService.getOne(configQuery);
        if (ObjectUtils.isEmpty(outboundConfig)) {
            throw new WmsBusinessException("出库配置未配置,请检查配置!");
        }
        /**
         * 根据入库明细配置序号升序排列生成任务
         * */
        LambdaQueryWrapper<WmsOutboundDetail> detailQuery = new LambdaQueryWrapper<>();
        detailQuery.eq(WmsOutboundDetail::getOutboundId, outboundConfig.getId());
        detailQuery.orderByAsc(WmsOutboundDetail::getSorter);
        List<WmsOutboundDetail> details = outboundDetailService.list(detailQuery);
        if (CollectionUtils.isEmpty(details)) {
            throw new WmsBusinessException("未查询到出库配置明细记录!");
        }
        return details;
    }

    private void generateDeviceTask(int deviceType, Object task, Object boundDetail) {
        if(task instanceof WmsPutAwayTask && boundDetail instanceof WmsInboundDetail){
            WmsPutAwayTask putAwayTask = (WmsPutAwayTask) task;
            WmsInboundDetail inboundDetail = (WmsInboundDetail)boundDetail;
            //根据设备类型生成不同的任务
            switch (deviceType){
                case 0:
                    //四向车任务
                    genInboundSxDeviceTask(putAwayTask,inboundDetail);
                    break;
                case 1:
                    //BCR任务
                    genInboundBcrDeviceTask(putAwayTask,inboundDetail);
                    break;
                case 2:
                    //输送线任务
                    genInboundTslDeviceTask(putAwayTask,inboundDetail);
                    break;
                case 3:
                    //提升机任务
                    genInboundElvDeviceTask(putAwayTask,inboundDetail);
                    break;
                default:
                    throw new WmsBusinessException("未实现该设备的任务!");
            }
        }else{
            WmsPickTask pickTask = (WmsPickTask)task;
            WmsOutboundDetail outboundDetail = (WmsOutboundDetail)boundDetail;
            //根据设备类型生成不同的任务
            switch (deviceType) {
                case 0:
                    //四向车任务
                    genOutboundSxDeviceTask(pickTask, outboundDetail);
                    break;
                case 1:
                    //BCR任务
                    genOutboundBcrDeviceTask(pickTask, outboundDetail);
                    break;
                case 2:
                    //输送线任务
                    genOutboundTslDeviceTask(pickTask, outboundDetail);
                    break;
                case 3:
                    //提升机任务
                    genOutboundElvDeviceTask(pickTask, outboundDetail);
                    break;
                default:
                    throw new WmsBusinessException("未实现该设备的任务!");
            }
        }
    }

    private void genOutboundElvDeviceTask(WmsPickTask pickTask, WmsOutboundDetail outboundDetail) {
        //先查询是否有已生成的任务
        LambdaQueryWrapper<WcsElevatorTask> taskQuery = new LambdaQueryWrapper<>();
        taskQuery.eq(WcsElevatorTask::getRelateCode, pickTask.getTaskNo());
        taskQuery.eq(WcsElevatorTask::getTaskType, WcsTaskTypeEnums.INBOUND_H.getValue());
        taskQuery.eq(WcsElevatorTask::getTaskStatus, TaskStatus.READY.getTaskProgress());
        WcsElevatorTask elevatorTask = elevatorTaskService.getOne(taskQuery);
        if (ObjectUtils.isEmpty(elevatorTask)) {
            elevatorTask = new WcsElevatorTask();
            String taskNo = businessService.genWmsBusinessCode("EV" + DateUtil.format(new Date(), "YYMMdd"), 8);
            elevatorTask.setRelateCode(pickTask.getTaskNo());
            elevatorTask.setTaskNo(taskNo);
            elevatorTask.setSource(outboundDetail.getSource());
            elevatorTask.setTarget(pickTask.getTarget());
            elevatorTask.setTaskStatus(TaskStatus.READY.getTaskProgress());
            elevatorTask.setTaskType(WcsTaskTypeEnums.INBOUND_H.getValue());
            elevatorTask.setPalletNo(pickTask.getContainerNo());
            elevatorTask.setPriority(5);
            elevatorTaskService.save(elevatorTask);
            //更新任务节点
            pickTask.setTaskNode(outboundDetail.getSorter());
            pickTaskService.updateById(pickTask);
        }
    }

    private void genOutboundTslDeviceTask(WmsPickTask pickTask, WmsOutboundDetail outboundDetail) {
        //先查询是否有已生成的任务
        LambdaQueryWrapper<WcsLineTask> taskQuery = new LambdaQueryWrapper<>();
        taskQuery.eq(WcsLineTask::getRelateCode, pickTask.getTaskNo());
        taskQuery.eq(WcsLineTask::getTaskType, WcsTaskTypeEnums.INBOUND_T.getValue());
        taskQuery.eq(WcsLineTask::getTaskStatus, TaskStatus.READY.getTaskProgress());
        WcsLineTask lineTask = lineTaskService.getOne(taskQuery);
        if (ObjectUtils.isEmpty(lineTask)) {
            lineTask = new WcsLineTask();
            String taskNo = businessService.genWmsBusinessCode("TS" + DateUtil.format(new Date(), "YYMMdd"), 8);
            lineTask.setRelateCode(pickTask.getTaskNo());
            lineTask.setTaskNo(taskNo);
            lineTask.setSource(outboundDetail.getSource());
            lineTask.setTarget(outboundDetail.getTarget());
            lineTask.setTaskStatus(TaskStatus.READY.getTaskProgress());
            lineTask.setTaskType(WcsTaskTypeEnums.INBOUND_T.getValue());
            lineTask.setPalletNo(pickTask.getContainerNo());
            lineTask.setPriority(5);
            lineTaskService.save(lineTask);
            //更新任务节点
            pickTask.setTaskNode(outboundDetail.getSorter());
            pickTaskService.updateById(pickTask);
        }
    }

    private void genOutboundBcrDeviceTask(WmsPickTask pickTask, WmsOutboundDetail outboundDetail) {
        //先查询是否有已生成的任务
        LambdaQueryWrapper<WcsBcrTask> taskQuery = new LambdaQueryWrapper<>();
        taskQuery.eq(WcsBcrTask::getRelateCode, pickTask.getTaskNo());
        taskQuery.eq(WcsBcrTask::getTaskStatus, TaskStatus.READY.getTaskProgress());
        WcsBcrTask bcrTask = wcsBcrTaskService.getOne(taskQuery);
        if (ObjectUtils.isEmpty(bcrTask)) {
            bcrTask = new WcsBcrTask();
            String taskNo = businessService.genWmsBusinessCode("BCR" + DateUtil.format(new Date(), "YYMMdd"), 7);
            bcrTask.setRelateCode(pickTask.getTaskNo());
            bcrTask.setTaskNo(taskNo);
            bcrTask.setSource(outboundDetail.getSource());
            bcrTask.setTaskStatus(TaskStatus.READY.getTaskProgress());
            bcrTask.setPalletNo(pickTask.getContainerNo());
            bcrTask.setPriority(5);
            wcsBcrTaskService.save(bcrTask);
            //更新任务节点
            pickTask.setTaskNode(outboundDetail.getSorter());
            pickTaskService.updateById(pickTask);
        }
    }

    private void genOutboundSxDeviceTask(WmsPickTask pickTask, WmsOutboundDetail outboundDetail) {
        //先查询是否有已生成的任务
        LambdaQueryWrapper<WcsFourWayTask> taskQuery = new LambdaQueryWrapper<>();
        taskQuery.eq(WcsFourWayTask::getRelateCode, pickTask.getTaskNo());
        taskQuery.eq(WcsFourWayTask::getTaskType, WcsTaskTypeEnums.INBOUND_SXC.getValue());
        taskQuery.eq(WcsFourWayTask::getTaskStatus, TaskStatus.READY.getTaskProgress());
        WcsFourWayTask fourWayTask = fourWayTaskService.getOne(taskQuery);
        if (ObjectUtils.isEmpty(fourWayTask)) {
            fourWayTask = new WcsFourWayTask();
            fourWayTask.setRelateCode(pickTask.getTaskNo());
            fourWayTask.setSource("");
            fourWayTask.setTarget(outboundDetail.getTarget());
            fourWayTask.setTaskStatus(com.yhy.wxzn.wcs.enums.TaskStatus.READY);
            fourWayTask.setTaskType(TaskType.IN);
            fourWayTask.setPalletNo(pickTask.getContainerNo());
            fourWayTask.setPriority(5);
            fourWayTask.setRgvProgress(RgvProgress.NOT_ASSIGNED_TO_RGV);
            fourWayTaskService.save(fourWayTask);
            //更新任务节点
            pickTask.setTaskNode(outboundDetail.getSorter());
            pickTaskService.updateById(pickTask);
        }
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void doContainerBind(String bindId) {
        WcsContainerBind bind = containerBindService.getById(bindId);
        /**
         * 王德发   WcsBcrTask
         * WcsContainerBind 的托盘码、起点、状态 -》 WcsBcrTask               入库扫码任务与容器读码任务区别？  WcsBcrTask任务什么时候生成的？  WcsBcrTask的getTpCode哪来的？
         * WcsBcrTask  的relationCode  -》 WmsPutAwayTask。id
         */
        LambdaQueryWrapper<WcsBcrTask> bcrQuery = new LambdaQueryWrapper<>();
        bcrQuery.eq(WcsBcrTask::getPalletNo,bind.getTpCode())
                .eq(WcsBcrTask::getSource,bind.getSource())
                .eq(WcsBcrTask::getTaskStatus, TaskStatus.READY.getTaskProgress())
                .orderByDesc(WcsBcrTask::getCreateTime);
        List<WcsBcrTask> taskList = wcsBcrTaskService.list(bcrQuery);
        if(!CollectionUtils.isEmpty(taskList)){
            dealBcrTask(taskList,bind);
        }
        bind.setStatus(WcsBindStatusEnums.FFB.getValue());
        containerBindService.updateById(bind);
    }


    private void dealBcrTask(List<WcsBcrTask> taskList,WcsContainerBind bind) {
        WcsBcrTask bcrTask = taskList.get(0);
        //根据相关单号查找对应的上架任务
        LambdaQueryWrapper<WmsPutAwayTask> taskQuery = new LambdaQueryWrapper<>();
        taskQuery.eq(WmsPutAwayTask::getTaskNo,bcrTask.getRelateCode())
                .eq(WmsPutAwayTask::getTaskStatus,WmsOrderStatusEnums.CLZ.getValue());
        WmsPutAwayTask putAwayTask = putAwayTaskService.getOne(taskQuery);
        //外检校验不通过生成回退任务
        if(!WcsDetectionEnums.NOR.getValue().equals(bind.getDetection())){
            genBackTransLineTask(putAwayTask,bind);
        }else{
            //更新任务状态
            bcrTask.setTaskStatus(TaskStatus.FINISH.getTaskProgress());
            wcsBcrTaskService.updateById(bcrTask);

            putAwayTask.setTaskNode(bcrTask.getPriority());
            putAwayTask.setTaskStatus(WmsOrderStatusEnums.CLZ.getValue());
            putAwayTaskService.updateById(putAwayTask);
        }
    }

    /**
     * 1:根据入库配置找对应的提升机1层点位获取设备信息
     * 2：生成任务绑定设备
     * */
    private void genInboundElvDeviceTask(WmsPutAwayTask putTask, WmsInboundDetail inboundDetail) {
        //先查询是否有已生成的任务
        LambdaQueryWrapper<WcsElevatorTask> taskQuery = new LambdaQueryWrapper<>();
        taskQuery.eq(WcsElevatorTask::getRelateCode,putTask.getTaskNo());
        taskQuery.eq(WcsElevatorTask::getTaskType,WcsTaskTypeEnums.INBOUND_HC.getValue());
        taskQuery.lt(WcsElevatorTask::getTaskStatus, TaskStatus.FINISH.getTaskProgress());
        WcsElevatorTask elevatorTask = elevatorTaskService.getOne(taskQuery);
        if(ObjectUtils.isEmpty(elevatorTask)){
            elevatorTask = new WcsElevatorTask();
            String taskNo = businessService.genWmsBusinessCode("EV"+ DateUtil.format(new Date(),"YYMMdd"), 8);
            elevatorTask.setRelateCode(putTask.getTaskNo());
            elevatorTask.setTaskNo(taskNo);
            WcsPlcProperty plcProperty = elevatorTaskService.findPlcPropertyByCoord(inboundDetail.getSource());
            elevatorTask.setTarget(inboundDetail.getSource());
            elevatorTask.setTaskStatus(TaskStatus.READY.getTaskProgress());
            elevatorTask.setTaskType(WcsTaskTypeEnums.INBOUND_HC.getValue());
            elevatorTask.setPalletNo(putTask.getContainerNo());
            elevatorTask.setDeviceCode(plcProperty.getDeviceId()+"");
            elevatorTask.setPriority(5);
            elevatorTaskService.save(elevatorTask);
        }
    }

    private void genInboundSxDeviceTask(WmsPutAwayTask putTask, WmsInboundDetail inboundDetail) {
        //先查询是否有已生成的任务
        LambdaQueryWrapper<WcsFourWayTask> taskQuery = new LambdaQueryWrapper<>();
        taskQuery.eq(WcsFourWayTask::getRelateCode,putTask.getTaskNo());
        taskQuery.eq(WcsFourWayTask::getTaskType,TaskType.IN.getTypeNum());
        taskQuery.lt(WcsFourWayTask::getTaskStatus, com.yhy.wxzn.wcs.enums.TaskStatus.FINISH.getTaskProgress());
        WcsFourWayTask fourWayTask = fourWayTaskService.getOne(taskQuery);
        if(ObjectUtils.isEmpty(fourWayTask)){
            fourWayTask = new WcsFourWayTask();
            fourWayTask.setRelateCode(putTask.getTaskNo());
            fourWayTask.setSource(inboundDetail.getSource());
            fourWayTask.setTarget(putTask.getTarget());
            fourWayTask.setTaskStatus(com.yhy.wxzn.wcs.enums.TaskStatus.READY);
            fourWayTask.setTaskType(TaskType.IN);
            fourWayTask.setPalletNo(putTask.getContainerNo());
            fourWayTask.setPriority(5);
            fourWayTask.setRgvProgress(RgvProgress.NOT_ASSIGNED_TO_RGV);
            fourWayTaskService.save(fourWayTask);
        }
    }

    private void genInboundTslDeviceTask(WmsPutAwayTask putTask, WmsInboundDetail inboundDetail) {
        //先查询是否有已生成的任务
        LambdaQueryWrapper<WcsLineTask> taskQuery = new LambdaQueryWrapper<>();
        taskQuery.eq(WcsLineTask::getRelateCode,putTask.getTaskNo());
        taskQuery.eq(WcsLineTask::getTaskType,WcsTaskTypeEnums.INBOUND_T.getValue());
        taskQuery.lt(WcsLineTask::getTaskStatus, TaskStatus.FINISH.getTaskProgress());
        WcsLineTask lineTask = lineTaskService.getOne(taskQuery);
        if(ObjectUtils.isEmpty(lineTask)){
            lineTask = new WcsLineTask();
            String taskNo = businessService.genWmsBusinessCode("TS"+ DateUtil.format(new Date(),"YYMMdd"), 8);
            lineTask.setRelateCode(putTask.getTaskNo());
            lineTask.setTaskNo(taskNo);
            lineTask.setSource(inboundDetail.getSource());
            lineTask.setTarget(inboundDetail.getTarget());
            lineTask.setTaskStatus(TaskStatus.READY.getTaskProgress());
            lineTask.setTaskType(WcsTaskTypeEnums.INBOUND_T.getValue());
            lineTask.setPalletNo(putTask.getContainerNo());
            lineTask.setPriority(5);
            lineTaskService.save(lineTask);
        }
    }

    @Deprecated
    private List<WmsInboundDetail> findInboundConfig(WmsAsn asn) {
        //查找入库配置
        LambdaQueryWrapper<WmsInboundConfig> configQuery = new LambdaQueryWrapper<>();
        configQuery.eq(WmsInboundConfig::getStatus, ValidEnums.ENABLE.getValue());
        configQuery.eq(WmsInboundConfig::getOrderType,asn.getOrderType());
        WmsInboundConfig inboundConfig = inboundConfigService.getOne(configQuery);
        if(ObjectUtils.isEmpty(inboundConfig)){
            throw new WmsBusinessException("入库配置未配置,请检查配置!");
        }
        /**
         * 根据入库明细配置序号升序排列生成任务
         * */
        LambdaQueryWrapper<WmsInboundDetail> detailQuery = new LambdaQueryWrapper<>();
        detailQuery.eq(WmsInboundDetail::getInboundId,inboundConfig.getId());
        detailQuery.orderByAsc(WmsInboundDetail::getSorter);
        List<WmsInboundDetail> details = inboundDetailService.list(detailQuery);
        if(CollectionUtils.isEmpty(details)){
            throw new WmsBusinessException("未查询到入库配置明细记录!");
        }
        return details;
    }

    /**
     * 电控进行回退
     * @param putTask
     * @param bind
     */
    @Deprecated
    private void genBackTransLineTask(WmsPutAwayTask putTask,WcsContainerBind bind) {
        //查询回退任务是否已生成
        LambdaQueryWrapper<WcsLineTask> taskQuery = new LambdaQueryWrapper<>();
        taskQuery.eq(WcsLineTask::getRelateCode,putTask.getTaskNo());
        taskQuery.eq(WcsLineTask::getSource,bind.getSource());
        taskQuery.lt(WcsLineTask::getTaskStatus, TaskStatus.FINISH.getTaskProgress());
        WcsLineTask lineTask = lineTaskService.getOne(taskQuery);
        if(ObjectUtils.isEmpty(lineTask)){
            lineTask = new WcsLineTask();
            String taskNo = businessService.genWmsBusinessCode("TS"+ DateUtil.format(new Date(),"YYMMdd"), 8);
            lineTask.setRelateCode(putTask.getTaskNo());
            lineTask.setTaskNo(taskNo);
            lineTask.setSource(bind.getSource());
            lineTask.setTarget("1");
            lineTask.setTaskStatus(TaskStatus.READY.getTaskProgress());
            lineTask.setTaskType(WcsTaskTypeEnums.SEND_BACK.getValue());
            lineTask.setPalletNo(putTask.getContainerNo());
            lineTask.setPriority(5);
            lineTaskService.save(lineTask);
            putTask.setTaskStatus(WmsOrderStatusEnums.CLZ.getValue());
            putAwayTaskService.updateById(putTask);
        }
    }

    private void genInboundBcrDeviceTask(WmsPutAwayTask putTask, WmsInboundDetail inboundDetail) {
        //先查询是否有已生成的任务
        LambdaQueryWrapper<WcsBcrTask> taskQuery = new LambdaQueryWrapper<>();
        taskQuery.eq(WcsBcrTask::getRelateCode,putTask.getTaskNo());
        taskQuery.lt(WcsBcrTask::getTaskStatus, TaskStatus.FINISH.getTaskProgress());
        WcsBcrTask bcrTask = wcsBcrTaskService.getOne(taskQuery);
        if(ObjectUtils.isEmpty(bcrTask)){
            bcrTask = new WcsBcrTask();
            String taskNo = businessService.genWmsBusinessCode("BCR"+ DateUtil.format(new Date(),"YYMMdd"), 7);
            bcrTask.setRelateCode(putTask.getTaskNo());
            bcrTask.setTaskNo(taskNo);
            bcrTask.setSource(inboundDetail.getSource());
            bcrTask.setTaskStatus(TaskStatus.READY.getTaskProgress());
            bcrTask.setPalletNo(putTask.getContainerNo());
            bcrTask.setPriority(inboundDetail.getSorter());//任务节点
            wcsBcrTaskService.save(bcrTask);
        }
    }

}
